package study;

import cn.hutool.core.date.Month;
import cn.hutool.core.io.FileTypeUtil;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.io.file.FileReader;
import cn.hutool.core.io.file.FileWriter;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;

import java.io.File;
import java.util.HashMap;
import java.util.Map;

/**
 * @author huan
 */
public class FileUtilAm {
    public static void main(String[] args) throws JsonProcessingException {
        FileReader fileReader = new FileReader("D:\\IDEAProject\\test\\a.txt");
        String result = fileReader.readString();
        System.out.println(result);
        File file = FileUtil.file("d:/IDEAProject/test/a.txt");
        String type = FileTypeUtil.getType(file);
        System.out.println(type);
        FileWriter writer = new FileWriter("d:/IDEAProject/test/a.txt");
        writer.write("test\r\n", true);
        String template = "{}爱{dddd}{}{}，就像老鼠爱大米";
        String str = StrUtil.format(template, 1, 3, 4);
        System.out.println(str);
        String uuid = IdUtil.randomUUID();
        System.out.println(uuid.toUpperCase());
        Map<String ,Object> map = new HashMap<>();
        map.put("1","{'1':'123'}");
        map.put("2","{'2':'456'}");
        ObjectMapper objectMapper = new ObjectMapper();
        String jsonStr = objectMapper.writeValueAsString(map);
        System.out.println("hh:"+jsonStr);
        System.out.println("map:"+map);
        String jsonOutput= JSON.toJSONString("123");
        System.out.println(jsonOutput);
        int mon = Month.JULY.getValue();
        System.out.println(mon);
    }
}